//******************************************************************;
//**!!!!!!!!!!!! START - USER INPUT - START  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*****************;
// Define the root directory to which all extracts will be output too;
// The following program will define directories for you;
global rootoutputDir agedisk4
// Define the root directory to which the code can be found. ;
// For example the directory this file is sitting in.;


// used to generate space directories. For example mine would be;
global DUAfolder sacarny-DUA51934
//
global projectName cohort_extraction_new

//// READ IN TOPLEVEL
! rm ~/readgit.txt -f
! git rev-parse --show-toplevel > ~/readgit.txt

file open gittag using "~/readgit.txt", read
file read gittag line
while r(eof)==0 {
   global rootgitlocation `line'
   file read gittag line
    }
file close gittag
! rm ~/readgit.txt -f

global programRoot $rootgitlocation

//**!!!!!!!!!!!! END - USER INPUT - END  !!!!!!!!!!!!!!!!!!!!!!!!!!!**;
//*******************************************************************;
//// READ IN BRANCH
! rm ~/readgit.txt -f
! git name-rev HEAD | sed --quiet 's/HEAD \(.*\)/\1/p' > ~/readgit.txt

file open gitbranch using "~/readgit.txt", read
file read gitbranch line
while r(eof)==0 {
   global branch `line'
   file read gitbranch line
    }
file close gitbranch
! rm ~/readgit.txt -f

//// READ IN VERION ID
! rm ~/readgit.txt -f
! git tag > ~/readgit.txt

file open gittag using "~/readgit.txt", read
file read gittag line
while r(eof)==0 {
   global versionid `line'
   file read gittag line
    }
file close gittag
! rm ~/readgit.txt -f

//global versionid=""
//global branch=""
di "verision $versionid :: $branch "

/// Master Stata directory log.
//// READ IN SERVER
! rm ~/readgit.txt -f
! uname -n > ~/readgit.txt

file open servername using "~/readgit.txt", read
file read servername line
while r(eof)==0 {
   global sname `line'
   file read servername line
   }

if "$sname" =="agesas1"{
   global spacedrv agesasscratch1
   }
if "$sname" =="agesas2"{
   global spacedrv agesasscratch2
   }
if "$sname" =="agesas3"{
   global spacedrv agesasscratch3
   }
forvalues i=1/50 {
    if "$sname" =="age`i'"{
        global spacedrv agescratch`i'
    }
}
file close servername
! rm ~/readgit.txt -f

//// READ IN USER
! rm ~/readgit.txt -f
! whoami > ~/readgit.txt

file open whoami using "~/readgit.txt", read
file read whoami line
while r(eof)==0 {
   global username `line'
   file read whoami line
    }
file close whoami
! rm ~/readgit.txt -f


di "USERNAME::$username"
di "SERVER::$sname -SPACE :: $spacedrv"

global rootout "/disk/$rootoutputDir/medicare.work/$DUAfolder/$username/$projectName/$versionid/$branch/"
di  "$rootout"

/// Raw Extract -- DATA IN
global indexex "$rootout/1cohort_extraction/indx"
global medex "$rootout/1cohort_extraction/medpar"
global carex "$rootout/1cohort_extraction/car"
global opex "$rootout/1cohort_extraction/op"

global cmbex "$rootout/2create_index_level_measures/combined/"
global costs "$rootout/2create_index_level_measures/xday_costs_raw/"
global comorbid "$rootout/2create_index_level_measures/last_yr_comorbid/"
global proc "$rootout/2create_index_level_measures/xday_flag_procedures/"
global combineex "$rootout/3merge_cohort_level_data/"

global exhcris "$rootout/0preProcess/hcris"
global inpos  "/disk/aging/medicare/code/ExtData/pos"
global inHRRzipxw "/disk/aging/medicare/code/ExtData/HRRxw"



/// Cost utilization directories--MAKE SURE IT MATCHE COSTUTIL IN SAS FILE
  global carRVU  "$rootout/2create_index_level_measures/xday_cost_utiladj/car"
  global costutil  "$rootout/2create_index_level_measures/xday_cost_utiladj"
! mkdir -p $carRVU



global texroot "$programRoot/tex_stats"

/* ***************************************************************************************; */
/* **COST UTILIZATION PROGRAMS-INPUT FILES INCLUDED WITH THE SAS PACK; */
/* ***************************************************************************************; */
/* * define libraries that allow access to the various directories specified above; */
/* * THESE FILES ARE FOUND ON THE NBER SERVERS; */

global APCdir "/disk/aging/medicare/code/AuxData/costUtilizationWeights/OPPS_APCweights"
global DRGdir "/disk/aging/medicare/code/AuxData/costUtilizationWeights/AIPPS_drgweights"
global PFSdir "/disk/aging/medicare/code/AuxData/costUtilizationWeights/PFS_rvuweights/fromMatFiedler_NivSubramanian"


